package com.cloudfun.campusshare.controller;

import com.cloudfun.campusshare.common.constant.AttachType;
import com.cloudfun.campusshare.common.response.BaseResult;
import com.cloudfun.campusshare.common.security.AuthRequired;
import com.cloudfun.campusshare.service.AttachmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @description:
 * @author: linyangping
 * @create: 2018-06-21 15:17
 **/
@Slf4j
@Api(value = "附件", description = "附件相关接口", position = 9)
@RestController
@RequestMapping("/v1/attachment")
public class AttachmentController {

    @Autowired
    private AttachmentService attachmentService;

    @ApiOperation(value = "上传附件", notes = "上传附件接口")
    @RequestMapping(method = RequestMethod.POST)
    @AuthRequired
    BaseResult<?> uploadAttachment(@RequestParam AttachType type,
                                   @ApiParam(value = "文件", required = true) @RequestParam MultipartFile file) {
        return attachmentService.uploadAttachment(type, file);
    }
}
